import { upload, del } from '@/utils/request'

// 上传结果类型
export interface UploadResult {
  url: string
  fileType: string
}

// 上传相关API
export const uploadApi = {
  // 上传图片
  uploadImage: (file: File): Promise<UploadResult> => {
    return upload<UploadResult>('/upload/image', file)
  },

  // 上传视频
  uploadVideo: (file: File): Promise<UploadResult> => {
    return upload<UploadResult>('/upload/video', file)
  },

  // 删除文件
  deleteFile: (fileUrl: string) => {
    return del(`/upload/file?fileUrl=${encodeURIComponent(fileUrl)}`)
  }
}
